package strategyorder

import (
	"fmt"
	"time"
)

// ========= 订单对象 =========
type Order struct {
	ID             string
	UserID         string
	Items          []OrderItem
	OrderDate      time.Time
	UserType       string // "new", "regular", "vip"
	MemberLevel    string // "basic", "gold", "platinum"
	Promotion      string // "none", "blackfriday", "double11"
	IsFirstOrder   bool
	CouponCode     string
	TotalAmount    float64
	DiscountAmount float64
	FinalAmount    float64
}

type OrderItem struct {
	ProductID string
	Name      string
	Price     float64
	Quantity  int
}

func NewOrder(userID string, items []OrderItem, userType, memberLevel, promotion string, isFirstOrder bool, couponCode string) *Order {
	total := 0.0
	for _, item := range items {
		total += item.Price * float64(item.Quantity)
	}

	return &Order{
		ID:           fmt.Sprintf("ORD-%d", time.Now().Unix()),
		UserID:       userID,
		Items:        items,
		OrderDate:    time.Now(),
		UserType:     userType,
		MemberLevel:  memberLevel,
		Promotion:    promotion,
		IsFirstOrder: isFirstOrder,
		CouponCode:   couponCode,
		TotalAmount:  total,
	}
}
